<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Classname_model extends CI_Model
{
	function __construct(){
        parent::__construct();
	}
	
	function get_all($num,$offset)
	{
		$this->db->order_by('class_id','ASC');
		return $this->db->get('class',$num,$offset)->result();
	}
	
	function get_num()
	{
		 return $this->db->get('class')->num_rows();          
	}
	
	function getid($id=0)
	{
		 $this->db->where('class_id',$id);
		 return $this->db->get('class')->row();
	}
	
	function get_list_country(){
		 $this->db->order_by('lb_country','ASC');
		 return $this->db->get('fm_country')->result();
	}
	
	function save($data)
	{
		 $id = (int)$this->uri->segment(3);
		 if($id != 0){
			  $this->db->where('class_id',$id);
			  if($this->db->update('class',$data)){
					return true;
			  }else{
					return false;
			  }
		 }else{
			  if($this->db->insert('class',$data)){
					return true;
			  }else{
					return false;
			  }
		 }          
	}
	
	function del($id)
	{
		 $this->db->where('class_id',$id);
		 if($this->db->delete('class')){
			  return true;
		 }else{
			  return false;
		 }
	}
}
